123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- CKEDITOR.dialog.add("twoGisLinkDialog", function(editor) {
- return {
- allowedContent: "a[href,target]",
- title: "Âñòàâüòå êëþ÷åâîå ñëîâî",
- minWidth: 550,
- minHeight: 100,
- resizable: CKEDITOR.DIALOG_RESIZE_NONE,
- contents:[{
- id: "Âñòàâüòå êëþ÷åâîå ñëîâî",
- label: "",
- elements:[{
- type: "text",
- label: "Êëþ÷åâîå ñëîâî äëÿ ïîèñêà",
- id: "edp-URL",
- validate: CKEDITOR.dialog.validate.notEmpty( "Ïîëå ñ êëþ÷åâûì ñëîâîì íå ìîæåò áûòü ïóñòûì" ),
- setup: function( element ) {
- var href = element.getAttribute("href");
- var isExternalURL = /^(http|https):\/\//;
- if(href) {
- if(!isExternalURL.test(href)) {
- href = "http://amic.ru/spravochnik/?s=" + href;
- }
- this.setValue(href);
- }
- },
- commit: function(element) {
- var href = this.getValue();
- var isExternalURL = /^(http|https):\/\//;
- if(href) {
- if(!isExternalURL.test(href)) {
- href = "http://amic.ru/spravochnik/?s=" + href;
- }
- element.setAttribute("href", href);
- if(!element.getText()) {
- element.setText(this.getValue());
- }
- }
- }
- }, {
- type: "text",
- label: "Âûäåëåííàÿ ÷àñòü òåêñòà",
- id: "edp-text-display",
- setup: function( element ) {
- this.setValue( element.getText() );
- },
- commit: function(element) {
- var currentValue = this.getValue();
- if(currentValue !== "" && currentValue !== null) {
- element.setText(currentValue);
- }
- }
- }, {
- type: "html",
- html: ""
- }]
- }],
- onShow: function() {
- var selection = editor.getSelection();
- var selector = selection.getStartElement()
- var element;
-
- if(selector) {
- element = selector.getAscendant( 'a', true );
- }
-
- if ( !element || element.getName() != 'a' ) {
- element = editor.document.createElement( 'a' );
- element.setAttribute("target","_blank");
- if(selection) {
- element.setText(selection.getSelectedText());
- }
- this.insertMode = true;
- }
- else {
- this.insertMode = false;
- }
-
- this.element = element;
-
-
- this.setupContent(this.element);
- },
- onOk: function() {
- var dialog = this;
- var anchorElement = this.element;
- this.element.setAttribute('id', 'twoGis')
- this.commitContent(this.element);
-
- if(this.insertMode) {
- editor.insertElement(this.element);
- }
- }
- };
- });
|