Revision 35584d80 ui/static/snf/js/utils.js

b/ui/static/snf/js/utils.js
141 141
        // TODO: implement me
142 142
    }
143 143

  
144
    synnefo.util.ClipHelper = function(cont, clear) {
145
        this.force_empty = clear || false;
146
        this.cont = cont || $('<div class="clip-copy"></div>');
147
        this.clip = new ZeroClipboard.Client();
148
        this.clip.setHandCursor(true);
149

  
150
        this.el = this.cont;
151
        if (this.force_empty) {
152
            this.cont.empty();
153
        }
154
        this.el.append(this.clip.getHTML(20,20));
155

  
156
        this.setText = function(t) {
157
            this.clip.setText(t);
158
        }
159

  
160
        var copy_prompt = "Click to copy to clipboard";
161
        this.el.attr({title: copy_prompt});
162
        this.el.tooltip();
163
        var el = this.el;
164

  
165
        this.clip.addEventListener('complete', _.bind(function(client, text) {
166
            var tip = el.data("tooltip")
167
            tip.hide().getTip().text("Copied");
168
            
169
            window.setTimeout(function() {
170
                tip.show();
171
            }, 70)
172

  
173
            window.setTimeout(function() {
174
                tip.hide().getTip().text(copy_prompt);
175
            }, 3000)
176
        }, this));
144
    synnefo.util.ClipHelper = function(wrapper, text, settings) {
145
        settings = settings || {};
146
        this.el = $('<div class="clip-copy"></div>');
147
        wrapper.append(this.el);
148
        this.clip = $(this.el).zclip(_.extend({
149
            path: synnefo.config.js_url + "lib/ZeroClipboard.swf",
150
            copy: text
151
        }, settings));
177 152
    }
178 153

  
179 154
    synnefo.util.truncate = function(string, size, append, words) {

Also available in: Unified diff