rails_kindeditor 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. data/lib/generators/rails_kindeditor/install/templates/kindeditor/kindeditor-min.js +165 -161
  2. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/en.js +210 -210
  3. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_CN.js +214 -214
  4. data/lib/generators/rails_kindeditor/install/templates/kindeditor/lang/zh_TW.js +212 -212
  5. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/anchor/anchor.js +46 -46
  6. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/clearhtml/clearhtml.js +29 -29
  7. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/filemanager/filemanager.js +189 -185
  8. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/flash/flash.js +145 -145
  9. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/image/image.js +259 -242
  10. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/insertfile/insertfile.js +109 -109
  11. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/link/link.js +65 -65
  12. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/map/map.js +137 -137
  13. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/media/media.js +153 -153
  14. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/pagebreak/pagebreak.js +26 -26
  15. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/table/table.js +715 -715
  16. data/lib/generators/rails_kindeditor/install/templates/kindeditor/plugins/wordpaste/wordpaste.js +51 -51
  17. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/common/loading.gif +0 -0
  18. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.css +991 -980
  19. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.png +0 -0
  20. data/lib/rails_kindeditor/version.rb +1 -1
  21. metadata +29 -51
  22. data/lib/generators/rails_kindeditor/install/templates/kindeditor/themes/default/default.gif +0 -0
@@ -1,109 +1,109 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
- KindEditor.plugin('insertfile', function(K) {
11
- var self = this, name = 'insertfile',
12
- allowFileManager = K.undef(self.allowFileManager, false),
13
- uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
14
- lang = self.lang(name + '.');
15
- self.clickToolbar(name, function() {
16
- var html = [
17
- '<div style="padding:10px 20px;">',
18
- '<div class="ke-dialog-row">',
19
- '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
20
- '<input type="text" id="keUrl" name="url" class="ke-input-text" style="width:160px;" /> &nbsp;',
21
- '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
22
- '<span class="ke-button-common ke-button-outer">',
23
- '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
24
- '</span>',
25
- '</div>',
26
- //title
27
- '<div class="ke-dialog-row">',
28
- '<label for="keTitle" style="width:60px;">' + lang.title + '</label>',
29
- '<input type="text" id="keTitle" class="ke-input-text" name="title" value="" style="width:160px;" /></div>',
30
- '</div>',
31
- //form end
32
- '</form>',
33
- '</div>'
34
- ].join('');
35
- var dialog = self.createDialog({
36
- name : name,
37
- width : 450,
38
- height : 180,
39
- title : self.lang(name),
40
- body : html,
41
- yesBtn : {
42
- name : self.lang('yes'),
43
- click : function(e) {
44
- var url = K.trim(urlBox.val()),
45
- title = titleBox.val();
46
- if (url == 'http://' || K.invalidUrl(url)) {
47
- alert(self.lang('invalidUrl'));
48
- urlBox[0].focus();
49
- return;
50
- }
51
- if (K.trim(title) === '') {
52
- title = url;
53
- }
54
- var html = '<a href="' + url + '" data-ke-src="' + url + '" target="_blank">' + title + '</a>';
55
- self.insertHtml(html);
56
- uploadbutton.remove();
57
- self.hideDialog().focus();
58
- }
59
- }
60
- }),
61
- div = dialog.div;
62
-
63
- var urlBox = K('[name="url"]', div),
64
- viewServerBtn = K('[name="viewServer"]', div),
65
- titleBox = K('[name="title"]', div);
66
-
67
- var uploadbutton = K.uploadbutton({
68
- button : K('.ke-upload-button', div)[0],
69
- fieldName : 'imgFile',
70
- url : K.addParam(uploadJson, 'dir=file'),
71
- afterUpload : function(data) {
72
- if (data.error === 0) {
73
- var url = K.formatUrl(data.url, 'absolute');
74
- urlBox.val(url);
75
- if (self.afterUpload) {
76
- self.afterUpload.call(self, url);
77
- }
78
- alert(self.lang('uploadSuccess'));
79
- } else {
80
- alert(data.message);
81
- }
82
- }
83
- });
84
- uploadbutton.fileBox.change(function(e) {
85
- uploadbutton.submit();
86
- });
87
- if (allowFileManager) {
88
- viewServerBtn.click(function(e) {
89
- self.loadPlugin('filemanager', function() {
90
- self.plugin.filemanagerDialog({
91
- viewType : 'LIST',
92
- dirName : 'file',
93
- clickFn : function(url, title) {
94
- if (self.dialogs.length > 1) {
95
- K('[name="url"]', div).val(url);
96
- self.hideDialog();
97
- }
98
- }
99
- });
100
- });
101
- });
102
- } else {
103
- viewServerBtn.hide();
104
- }
105
- urlBox.val('http://');
106
- urlBox[0].focus();
107
- urlBox[0].select();
108
- });
109
- });
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ KindEditor.plugin('insertfile', function(K) {
11
+ var self = this, name = 'insertfile',
12
+ allowFileManager = K.undef(self.allowFileManager, false),
13
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
14
+ lang = self.lang(name + '.');
15
+ self.clickToolbar(name, function() {
16
+ var html = [
17
+ '<div style="padding:10px 20px;">',
18
+ '<div class="ke-dialog-row">',
19
+ '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
20
+ '<input type="text" id="keUrl" name="url" class="ke-input-text" style="width:160px;" /> &nbsp;',
21
+ '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
22
+ '<span class="ke-button-common ke-button-outer">',
23
+ '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
24
+ '</span>',
25
+ '</div>',
26
+ //title
27
+ '<div class="ke-dialog-row">',
28
+ '<label for="keTitle" style="width:60px;">' + lang.title + '</label>',
29
+ '<input type="text" id="keTitle" class="ke-input-text" name="title" value="" style="width:160px;" /></div>',
30
+ '</div>',
31
+ //form end
32
+ '</form>',
33
+ '</div>'
34
+ ].join('');
35
+ var dialog = self.createDialog({
36
+ name : name,
37
+ width : 450,
38
+ height : 180,
39
+ title : self.lang(name),
40
+ body : html,
41
+ yesBtn : {
42
+ name : self.lang('yes'),
43
+ click : function(e) {
44
+ var url = K.trim(urlBox.val()),
45
+ title = titleBox.val();
46
+ if (url == 'http://' || K.invalidUrl(url)) {
47
+ alert(self.lang('invalidUrl'));
48
+ urlBox[0].focus();
49
+ return;
50
+ }
51
+ if (K.trim(title) === '') {
52
+ title = url;
53
+ }
54
+ var html = '<a href="' + url + '" data-ke-src="' + url + '" target="_blank">' + title + '</a>';
55
+ self.insertHtml(html);
56
+ uploadbutton.remove();
57
+ self.hideDialog().focus();
58
+ }
59
+ }
60
+ }),
61
+ div = dialog.div;
62
+
63
+ var urlBox = K('[name="url"]', div),
64
+ viewServerBtn = K('[name="viewServer"]', div),
65
+ titleBox = K('[name="title"]', div);
66
+
67
+ var uploadbutton = K.uploadbutton({
68
+ button : K('.ke-upload-button', div)[0],
69
+ fieldName : 'imgFile',
70
+ url : K.addParam(uploadJson, 'dir=file'),
71
+ afterUpload : function(data) {
72
+ if (data.error === 0) {
73
+ var url = K.formatUrl(data.url, 'absolute');
74
+ urlBox.val(url);
75
+ if (self.afterUpload) {
76
+ self.afterUpload.call(self, url);
77
+ }
78
+ alert(self.lang('uploadSuccess'));
79
+ } else {
80
+ alert(data.message);
81
+ }
82
+ }
83
+ });
84
+ uploadbutton.fileBox.change(function(e) {
85
+ uploadbutton.submit();
86
+ });
87
+ if (allowFileManager) {
88
+ viewServerBtn.click(function(e) {
89
+ self.loadPlugin('filemanager', function() {
90
+ self.plugin.filemanagerDialog({
91
+ viewType : 'LIST',
92
+ dirName : 'file',
93
+ clickFn : function(url, title) {
94
+ if (self.dialogs.length > 1) {
95
+ K('[name="url"]', div).val(url);
96
+ self.hideDialog();
97
+ }
98
+ }
99
+ });
100
+ });
101
+ });
102
+ } else {
103
+ viewServerBtn.hide();
104
+ }
105
+ urlBox.val('http://');
106
+ urlBox[0].focus();
107
+ urlBox[0].select();
108
+ });
109
+ });
@@ -1,65 +1,65 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
- KindEditor.plugin('link', function(K) {
11
- var self = this, name = 'link';
12
- self.plugin.link = {
13
- edit : function() {
14
- var lang = self.lang(name + '.'),
15
- html = '<div style="padding:10px 20px;">' +
16
- //url
17
- '<div class="ke-dialog-row">' +
18
- '<label for="keUrl">' + lang.url + '</label>' +
19
- '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:90%;" /></div>' +
20
- //type
21
- '<div class="ke-dialog-row"">' +
22
- '<label for="keType">' + lang.linkType + '</label>' +
23
- '<select id="keType" name="type"></select>' +
24
- '</div>' +
25
- '</div>',
26
- dialog = self.createDialog({
27
- name : name,
28
- width : 400,
29
- title : self.lang(name),
30
- body : html,
31
- yesBtn : {
32
- name : self.lang('yes'),
33
- click : function(e) {
34
- var url = K.trim(urlBox.val());
35
- if (url == 'http://' || K.invalidUrl(url)) {
36
- alert(self.lang('invalidUrl'));
37
- urlBox[0].focus();
38
- return;
39
- }
40
- self.exec('createlink', url, typeBox.val()).hideDialog().focus();
41
- }
42
- }
43
- }),
44
- div = dialog.div,
45
- urlBox = K('input[name="url"]', div),
46
- typeBox = K('select[name="type"]', div);
47
- urlBox.val('http://');
48
- typeBox[0].options[0] = new Option(lang.newWindow, '_blank');
49
- typeBox[0].options[1] = new Option(lang.selfWindow, '');
50
- var a = self.plugin.getSelectedLink();
51
- if (a) {
52
- self.cmd.range.selectNode(a[0]);
53
- self.cmd.select();
54
- urlBox.val(a.attr('data-ke-src'));
55
- typeBox.val(a.attr('target'));
56
- }
57
- urlBox[0].focus();
58
- urlBox[0].select();
59
- },
60
- 'delete' : function() {
61
- self.exec('unlink', null);
62
- }
63
- };
64
- self.clickToolbar(name, self.plugin.link.edit);
65
- });
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ KindEditor.plugin('link', function(K) {
11
+ var self = this, name = 'link';
12
+ self.plugin.link = {
13
+ edit : function() {
14
+ var lang = self.lang(name + '.'),
15
+ html = '<div style="padding:10px 20px;">' +
16
+ //url
17
+ '<div class="ke-dialog-row">' +
18
+ '<label for="keUrl">' + lang.url + '</label>' +
19
+ '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:90%;" /></div>' +
20
+ //type
21
+ '<div class="ke-dialog-row"">' +
22
+ '<label for="keType">' + lang.linkType + '</label>' +
23
+ '<select id="keType" name="type"></select>' +
24
+ '</div>' +
25
+ '</div>',
26
+ dialog = self.createDialog({
27
+ name : name,
28
+ width : 400,
29
+ title : self.lang(name),
30
+ body : html,
31
+ yesBtn : {
32
+ name : self.lang('yes'),
33
+ click : function(e) {
34
+ var url = K.trim(urlBox.val());
35
+ if (url == 'http://' || K.invalidUrl(url)) {
36
+ alert(self.lang('invalidUrl'));
37
+ urlBox[0].focus();
38
+ return;
39
+ }
40
+ self.exec('createlink', url, typeBox.val()).hideDialog().focus();
41
+ }
42
+ }
43
+ }),
44
+ div = dialog.div,
45
+ urlBox = K('input[name="url"]', div),
46
+ typeBox = K('select[name="type"]', div);
47
+ urlBox.val('http://');
48
+ typeBox[0].options[0] = new Option(lang.newWindow, '_blank');
49
+ typeBox[0].options[1] = new Option(lang.selfWindow, '');
50
+ var a = self.plugin.getSelectedLink();
51
+ if (a) {
52
+ self.cmd.range.selectNode(a[0]);
53
+ self.cmd.select();
54
+ urlBox.val(a.attr('data-ke-src'));
55
+ typeBox.val(a.attr('target'));
56
+ }
57
+ urlBox[0].focus();
58
+ urlBox[0].select();
59
+ },
60
+ 'delete' : function() {
61
+ self.exec('unlink', null);
62
+ }
63
+ };
64
+ self.clickToolbar(name, self.plugin.link.edit);
65
+ });
@@ -1,137 +1,137 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
- // Google Maps: http://code.google.com/apis/maps/index.html
11
-
12
- KindEditor.plugin('map', function(K) {
13
- var self = this, name = 'map', lang = self.lang(name + '.');
14
- self.clickToolbar(name, function() {
15
- var html = ['<div style="padding:10px 20px;">',
16
- '<div class="ke-dialog-row">',
17
- lang.address + ' <input id="kindeditor_plugin_map_address" name="address" class="ke-input-text" value="" style="width:200px;" /> ',
18
- '<span class="ke-button-common ke-button-outer">',
19
- '<input type="button" name="searchBtn" class="ke-button-common ke-button" value="' + lang.search + '" />',
20
- '</span>',
21
- '</div>',
22
- '<div class="ke-map" style="width:558px;height:360px;"></div>',
23
- '</div>'].join('');
24
- var dialog = self.createDialog({
25
- name : name,
26
- width : 600,
27
- title : self.lang(name),
28
- body : html,
29
- yesBtn : {
30
- name : self.lang('yes'),
31
- click : function(e) {
32
- var geocoder = win.geocoder,
33
- map = win.map,
34
- center = map.getCenter().lat() + ',' + map.getCenter().lng(),
35
- zoom = map.getZoom(),
36
- maptype = map.getMapTypeId(),
37
- url = 'http://maps.googleapis.com/maps/api/staticmap';
38
- url += '?center=' + encodeURIComponent(center);
39
- url += '&zoom=' + encodeURIComponent(zoom);
40
- url += '&size=558x360';
41
- url += '&maptype=' + encodeURIComponent(maptype);
42
- url += '&markers=' + encodeURIComponent(center);
43
- url += '&language=' + self.langType;
44
- url += '&sensor=false';
45
- self.exec('insertimage', url).hideDialog().focus();
46
- }
47
- },
48
- beforeRemove : function() {
49
- searchBtn.remove();
50
- if (doc) {
51
- doc.write('');
52
- }
53
- iframe.remove();
54
- }
55
- });
56
- var div = dialog.div,
57
- addressBox = K('[name="address"]', div),
58
- searchBtn = K('[name="searchBtn"]', div),
59
- win, doc;
60
- var iframeHtml = ['<!doctype html><html><head>',
61
- '<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />',
62
- '<style>',
63
- ' html { height: 100% }',
64
- ' body { height: 100%; margin: 0; padding: 0; background-color: #FFF }',
65
- ' #map_canvas { height: 100% }',
66
- '</style>',
67
- '<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=' + self.langType + '"></script>',
68
- '<script>',
69
- 'var map, geocoder;',
70
- 'function initialize() {',
71
- ' var latlng = new google.maps.LatLng(31.230393, 121.473704);',
72
- ' var options = {',
73
- ' zoom: 11,',
74
- ' center: latlng,',
75
- ' disableDefaultUI: true,',
76
- ' panControl: true,',
77
- ' zoomControl: true,',
78
- ' mapTypeControl: true,',
79
- ' scaleControl: true,',
80
- ' streetViewControl: false,',
81
- ' overviewMapControl: true,',
82
- ' mapTypeId: google.maps.MapTypeId.ROADMAP',
83
- ' };',
84
- ' map = new google.maps.Map(document.getElementById("map_canvas"), options);',
85
- ' geocoder = new google.maps.Geocoder();',
86
- ' geocoder.geocode({latLng: latlng}, function(results, status) {',
87
- ' if (status == google.maps.GeocoderStatus.OK) {',
88
- ' if (results[3]) {',
89
- ' parent.document.getElementById("kindeditor_plugin_map_address").value = results[3].formatted_address;',
90
- ' }',
91
- ' }',
92
- ' });',
93
- '}',
94
- 'function search(address) {',
95
- ' if (!map) return;',
96
- ' geocoder.geocode({address : address}, function(results, status) {',
97
- ' if (status == google.maps.GeocoderStatus.OK) {',
98
- ' map.setZoom(11);',
99
- ' map.setCenter(results[0].geometry.location);',
100
- ' var marker = new google.maps.Marker({',
101
- ' map: map,',
102
- ' position: results[0].geometry.location',
103
- ' });',
104
- ' } else {',
105
- ' alert("Invalid address: " + address);',
106
- ' }',
107
- ' });',
108
- '}',
109
- '</script>',
110
- '</head>',
111
- '<body onload="initialize();">',
112
- '<div id="map_canvas" style="width:100%; height:100%"></div>',
113
- '</body></html>'].join('\n');
114
- // TODO:用doc.write(iframeHtml)方式加载时,在IE6上第一次加载报错,暂时使用src方式
115
- var iframe = K('<iframe class="ke-textarea" frameborder="0" src="' + self.pluginsPath + 'map/map.html" style="width:558px;height:360px;"></iframe>');
116
- function ready() {
117
- win = iframe[0].contentWindow;
118
- doc = K.iframeDoc(iframe);
119
- //doc.open();
120
- //doc.write(iframeHtml);
121
- //doc.close();
122
- }
123
- iframe.bind('load', function() {
124
- iframe.unbind('load');
125
- if (K.IE) {
126
- ready();
127
- } else {
128
- setTimeout(ready, 0);
129
- }
130
- });
131
- K('.ke-map', div).replaceWith(iframe);
132
- // search map
133
- searchBtn.click(function() {
134
- win.search(addressBox.val());
135
- });
136
- });
137
- });
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+ // Google Maps: http://code.google.com/apis/maps/index.html
11
+
12
+ KindEditor.plugin('map', function(K) {
13
+ var self = this, name = 'map', lang = self.lang(name + '.');
14
+ self.clickToolbar(name, function() {
15
+ var html = ['<div style="padding:10px 20px;">',
16
+ '<div class="ke-dialog-row">',
17
+ lang.address + ' <input id="kindeditor_plugin_map_address" name="address" class="ke-input-text" value="" style="width:200px;" /> ',
18
+ '<span class="ke-button-common ke-button-outer">',
19
+ '<input type="button" name="searchBtn" class="ke-button-common ke-button" value="' + lang.search + '" />',
20
+ '</span>',
21
+ '</div>',
22
+ '<div class="ke-map" style="width:558px;height:360px;"></div>',
23
+ '</div>'].join('');
24
+ var dialog = self.createDialog({
25
+ name : name,
26
+ width : 600,
27
+ title : self.lang(name),
28
+ body : html,
29
+ yesBtn : {
30
+ name : self.lang('yes'),
31
+ click : function(e) {
32
+ var geocoder = win.geocoder,
33
+ map = win.map,
34
+ center = map.getCenter().lat() + ',' + map.getCenter().lng(),
35
+ zoom = map.getZoom(),
36
+ maptype = map.getMapTypeId(),
37
+ url = 'http://maps.googleapis.com/maps/api/staticmap';
38
+ url += '?center=' + encodeURIComponent(center);
39
+ url += '&zoom=' + encodeURIComponent(zoom);
40
+ url += '&size=558x360';
41
+ url += '&maptype=' + encodeURIComponent(maptype);
42
+ url += '&markers=' + encodeURIComponent(center);
43
+ url += '&language=' + self.langType;
44
+ url += '&sensor=false';
45
+ self.exec('insertimage', url).hideDialog().focus();
46
+ }
47
+ },
48
+ beforeRemove : function() {
49
+ searchBtn.remove();
50
+ if (doc) {
51
+ doc.write('');
52
+ }
53
+ iframe.remove();
54
+ }
55
+ });
56
+ var div = dialog.div,
57
+ addressBox = K('[name="address"]', div),
58
+ searchBtn = K('[name="searchBtn"]', div),
59
+ win, doc;
60
+ var iframeHtml = ['<!doctype html><html><head>',
61
+ '<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />',
62
+ '<style>',
63
+ ' html { height: 100% }',
64
+ ' body { height: 100%; margin: 0; padding: 0; background-color: #FFF }',
65
+ ' #map_canvas { height: 100% }',
66
+ '</style>',
67
+ '<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=' + self.langType + '"></script>',
68
+ '<script>',
69
+ 'var map, geocoder;',
70
+ 'function initialize() {',
71
+ ' var latlng = new google.maps.LatLng(31.230393, 121.473704);',
72
+ ' var options = {',
73
+ ' zoom: 11,',
74
+ ' center: latlng,',
75
+ ' disableDefaultUI: true,',
76
+ ' panControl: true,',
77
+ ' zoomControl: true,',
78
+ ' mapTypeControl: true,',
79
+ ' scaleControl: true,',
80
+ ' streetViewControl: false,',
81
+ ' overviewMapControl: true,',
82
+ ' mapTypeId: google.maps.MapTypeId.ROADMAP',
83
+ ' };',
84
+ ' map = new google.maps.Map(document.getElementById("map_canvas"), options);',
85
+ ' geocoder = new google.maps.Geocoder();',
86
+ ' geocoder.geocode({latLng: latlng}, function(results, status) {',
87
+ ' if (status == google.maps.GeocoderStatus.OK) {',
88
+ ' if (results[3]) {',
89
+ ' parent.document.getElementById("kindeditor_plugin_map_address").value = results[3].formatted_address;',
90
+ ' }',
91
+ ' }',
92
+ ' });',
93
+ '}',
94
+ 'function search(address) {',
95
+ ' if (!map) return;',
96
+ ' geocoder.geocode({address : address}, function(results, status) {',
97
+ ' if (status == google.maps.GeocoderStatus.OK) {',
98
+ ' map.setZoom(11);',
99
+ ' map.setCenter(results[0].geometry.location);',
100
+ ' var marker = new google.maps.Marker({',
101
+ ' map: map,',
102
+ ' position: results[0].geometry.location',
103
+ ' });',
104
+ ' } else {',
105
+ ' alert("Invalid address: " + address);',
106
+ ' }',
107
+ ' });',
108
+ '}',
109
+ '</script>',
110
+ '</head>',
111
+ '<body onload="initialize();">',
112
+ '<div id="map_canvas" style="width:100%; height:100%"></div>',
113
+ '</body></html>'].join('\n');
114
+ // TODO:用doc.write(iframeHtml)方式加载时,在IE6上第一次加载报错,暂时使用src方式
115
+ var iframe = K('<iframe class="ke-textarea" frameborder="0" src="' + self.pluginsPath + 'map/map.html" style="width:558px;height:360px;"></iframe>');
116
+ function ready() {
117
+ win = iframe[0].contentWindow;
118
+ doc = K.iframeDoc(iframe);
119
+ //doc.open();
120
+ //doc.write(iframeHtml);
121
+ //doc.close();
122
+ }
123
+ iframe.bind('load', function() {
124
+ iframe.unbind('load');
125
+ if (K.IE) {
126
+ ready();
127
+ } else {
128
+ setTimeout(ready, 0);
129
+ }
130
+ });
131
+ K('.ke-map', div).replaceWith(iframe);
132
+ // search map
133
+ searchBtn.click(function() {
134
+ win.search(addressBox.val());
135
+ });
136
+ });
137
+ });